<template>
	<view>
		<swiper :indicator-dots="true" :autoplay="true" :interval="3000" :duration="1000" :circular="true" class="swiper_image">
			<swiper-item v-for="(item,index) in BannersList" class="swiper_image">
				<image :src="image+item.img" mode="aspectFill" class="bg-gray swiper_image"></image>
			</swiper-item>
		</swiper>
		<view class="gonggao">
			<swiper :indicator-dots="false" :vertical='true' :circular="true" :interval="3000" :duration="1000" autoplay="true"
			 style="height: 100rpx;">
				<swiper-item v-for="(item,index) in announcementList" class="align-center" @click="$tools.Router('/pages/home/announcementDetail/announcementDetail?title='+item.title+'&content='+item.content)">
					<view class="align-center margin-left">
						<image src="/static/icon/gonggao.png" mode="widthFix" style="height: 50rpx;width: 50rpx;"></image>
						<view class="margin-left-sm text-black onelineshow text-lg">
							{{item.title}}
						</view>
					</view>
				</swiper-item>
			</swiper>
		</view>
		<view class="bg-white rowsb padding classify" v-if="isPs ==0">
			<view v-for="(item,index) in classifyList" @click="classifyMen(index)">
				<view class="text-center">
					<image :src="item.image" mode="" class="classify_size"></image>
				</view>
				<view class="margin-top-xs">
					{{item.title}}
				</view>
			</view>
		</view>
		<view class=" bg-white ">
			<view class="flex ">
				<view class=" padding-sm text-lg margin-left" style="color: #0054A7;border-bottom: 4rpx solid #0054A7;">
					报名专区
				</view>
			</view>
		</view>
		<view>
			<view class=" bg-white flex rowsb padding-lr flex-wrap" style="padding-bottom: 100rpx;">
				<view style="width: 47%;" class="bg-white radius margin-top" v-for="(item,index) in signUpData" @click="commodityDetail(item.id)">
					<view>
						<image :src="image+item.img" mode="aspectFill" style="height: 312rpx;width: 100%;" class="bg-gray radius"></image>
					</view>
					<view class=" padding-bottom">
						<view>
							<view class="text-lg">{{item.title}}</view>
							<view class="text-gray" style="text-decoration:line-through">￥{{item.old_price}}</view>
						</view>
						<view class="rowsb align-center">
							<view class="text-red ">￥{{item.price}}</view>
							<view class="text-sm">{{item.sale_num}}人付款</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view class="warp align-center rowsc" v-if="deleteOrderinfo">
			<view class="margin-xl padding bg-gray radius" style="background-color: #FFFFFF;width: 70%;">
				<view class="text-center  padding-bottom border-bottom">
					<view class="text-bold">
						温馨提示
					</view>
					<view class="text-gray margin-top">您还未登录是否跳转登录？</view>
				</view>
				<view class="flex justify-around text-xl margin-top">
					<view class="solid-right" @click="deleteOrderinfo=false">
						取消
					</view>
					<view class="" style="color: #007AFF;" @click="login()">确定</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	const app = getApp().globalData
	import {
		announcement,
		getPlatformBanner,
		signUpList,
		get_ps
	} from '../../../common/path.js'
	export default {
		data() {
			return {
				deleteOrderinfo: false, //登录弹窗
				classifyList: [{
						title: '报名驾校',
						image: '/static/icon/icon_bmjx.png'
					},
					{
						title: '在线约车',
						image: '/static/icon/icon_zxyc.png'
					}, {
						title: '驾校活动',
						image: '/static/icon/icon_jxhd.png'
					},
					{
						title: '模拟考试',
						image: '/static/icon/icon_mnks.png'
					}
				],
				announcementList: [], //公告
				BannersList: [], //轮播图
				signUpData: [], //报名列表
				image: '',
				isPs:1
			}
		},
		onShow() {
			this.image = app.image
			console.log(this.image)
			if (uni.getStorageSync('userInfo') == '') {
				this.deleteOrderinfo = true
			}
			//获取轮播图，公告，报名列表
			this.announcement()
			//获取报名列表
		},
		onLoad() {
			this.get_ps()
		},
		
		methods: {
			get_ps(){
				this.$axios.axios('POST',get_ps,{}).then(res=>{
					this.isPs = res.data
					console.log('[审核]',this.isPs);
				})
			},
			//获取公告
			announcement() {
				//公告
				this.$axios.axios('POST', announcement, {}).then(res => {
					this.announcementList = res.data
				})
				//轮播图
				this.$axios.axios('POST', getPlatformBanner, {}).then(res => {
					this.BannersList = res.data
				})
				this.$axios.axios('POST', signUpList, {}).then(res => {
					this.signUpData = res.data
				})
			},
			classifyMen(index) {
				if (index == 0) {
					uni.navigateTo({
						url: '../applydrivingSchool/applydrivingSchool'
					})
				} else if (index == 1) {
					uni.navigateTo({
						url: '../aboutVehicle/aboutVehicle'
					})
				} else if (index == 2) {
					uni.navigateTo({
						url: '../activity/activity'
					})
				} else if (index == 3) {
					uni.navigateTo({
						url: '../examination/examination'
					})
				}

			},
			//登录跳转
			login() {
				uni.navigateTo({
					url: '/pages/login/login'
				})



			},
			//详情
			commodityDetail(id) {
				console.log()
				uni.navigateTo({
					url: '../commodityDetail/commodityDetail?id=' + id
				})
			},
			
			
			
			
			// -------------------------------------------------------------------------
			/**
			 * @param {Object} event- 用来判断是微信好友分享还是公众号分享
			 */
			shareMen(event) {
				let self = this
				// #ifdef APP-PLUS
				let pages = getCurrentPages()
				let len = pages.length
				let curParam = pages[len - 1].options //获取当前页面参数
				let param = []
				for (let key in curParam) { //获取key=value键值对格式数组
					param.push(key + '=' + curParam[key])
				}
				let _url = '' //除去第一个参数拼接后面参数
				param.forEach((item, i) => {
					if (i != 0) { //拼接&符号，由于第一组前拼接的是？所有第一组需要单独处理
						_url += '&' + item
					}
				})
				let url = '/' + pages[len - 1].route + '?' + param[0] +
					_url //最终格式**/pages/index/index/?id=11&name='boyyang'&sex='man'**
				let href = this.$paths.shareUrl + url
				let scene;
				if (event == 0) scene = 'WXSceneSession'
				else scene = 'WXSenceTimeline'
				uni.share({
					provider: "weixin",
					scene: scene,
					type: event,
					href: href + '',
					title: this.issueData.introduce + '',
					summary: this.issueData.introduce + '',
					imageUrl: this.issueData.images[0] + '',
					success: function(res) {
						self.setShareAddApi()
						self.$tools.showToast('分享成功')
					},
					fail: function(err) {
						self.$tools.showToast('分享失败')
					}
				});
				// #endif
			},
			/**
			 * @param {Object} event - 接收到到参数值
			 * @param {Object} index - 下标
			 * @param {Object} eveTop - 用来判断是不是删除父级评论
			 * @param {Object} event01 - 子级评论
			 * @param {Object} index01 - 评论子级下标
			 */
			longDetailCommon(event, index, eveTop, event01, index01) {
				let that = this
				let userId = app.userInfo.id
				if (event.userid == userId || event01.userid == userId) {
					console.log('[event]', event, index, eveTop, event01, index01);
					uni.showModal({
						title: '温馨提示',
						content: '确定要删除该条评论吗？',
						success: function(Res) {
							if (Res.confirm) {
								that.setCommentDelete(event, index, eveTop, event01, index01)
							} else if (Res.cancel) {
								console.log('用户点击取消');
							}
						}
					})
				}
			},
			//删除评论
			setCommentDelete(event, index, eveTop, event01, index01) {
				console.log('[event]', event, index, eveTop, event01, index01);
				let data = {}
				if (eveTop == 0) { //1级评论删除
					data = {
						id: event.id
					}
				} else { //2级评论删除
					data = {
						id: event01.id
					}
				}
			
			
				this.$axios.axiosFrom('POST', setCommentDelete, data)
					.then((res) => {
						console.log('[评论删除]', res);
						if (res.code == 1) { //1级评论删除
							if (eveTop == 0) {
								this.modalName3 = 'null'
								setTimeout(r => {
									this.commentList.splice(index, 1)
									this.issueData.reply_count--
								}, 100)
								setTimeout(r => {
									this.$tools.showToast2('评论删除成功')
								}, 600)
							} else if (eveTop == 1) { // 2级评论删除
								setTimeout(r => {
									let object = this.commentList[index].pdata
									console.log('[2级参数]', object);
									object.splice(index01, 1)
									this.issueData.reply_count--
									this.$tools.showToast2('评论删除成功')
								}, 100)
							} else {
								setTimeout(r => {
									let object = event.pdata
									console.log('[2级参数]', object);
									object.splice(index01, 1)
									this.issueData.reply_count--
									this.$tools.showToast2('评论删除成功')
								}, 100)
							}
						} else {
							this.$tools.showToast('评论删除失败')
						}
					})
			},
			
			/**
			 * @param 1元快问
			 */
			isCancelMen() {
				this.circuseePryApi()
			},
			
			
			//名师主页跳转
			issueDataMen2(event) {
				console.log(event.ms_id);
				this.$tools.push('/pages/teacher/teacherHome?id=' + event.ms_id)
			},
			//评论主页身份跳转
			homeToUrl(event) {
				console.log('评论', event);
				if (event.typedata == 1) {
					this.$tools.push('/pages/user/userHome/index?id=' + event.userid)
				} else {
					this.$tools.push('/pages/teacher/teacherHome?id=' + event.userid)
				}
			},
			
			//图片上传
			ChooseImage() {
				uni.chooseImage({
					count: 9,
					sizeType: ['compressed'], // 可以指定是原图还是压缩图，默认二者都有
					sourceType: ['album', 'camera'], // 可以指定来源是相册还是相机，默认二者都有
					success: (event) => {
						uni.showLoading({
							'title': '上传中...'
						})
						event.tempFilePaths.forEach(item => {
							uni.uploadFile({
								url: 'https://m.yipanxueyuan.com/addons/alioss/index/upload',
								filePath: item,
								name: 'file',
								formData: {
									token: uni.getStorageSync('token'),
								},
								success: (res) => {
									let analysisImg = JSON.parse(res.data)
									this.imgList.push(analysisImg.data.url)
									uni.hideLoading()
			
			
								},
								complete() {
									uni.hideLoading()
								}
			
							})
						})
			
					}
				})
			},
			//回答图片
			addUpImage() {
				let data = {
					data: this.imgList.toString(),
					order_id: this.issueId,
					states: this.recordTypeData, //1回答 2追问 3 追答
					type: 2, //文字
			
				}
				this.$axios.axiosFrom('POST', addAnswer, data)
					.then((res) => {
						if (res.code == 1) {
							this.isRecordType = 'put'
							this.isUpimage = false
							this.answerPage = 999999 //展开
							this.isRecordType = 'put'
							this.$tools.showToast('图片发送成功')
							this.answerListApi() //刷新
						} else {
							this.$tools.showToast(res.msg)
						}
					})
			},
			DelImg(e) {
				uni.showModal({
					title: '温馨提示',
					content: '确定要删除该图片吗？',
					cancelText: '取消',
					confirmText: '确定',
					success: res => {
						if (res.confirm) {
							this.imgList.splice(e.currentTarget.dataset.index, 1)
						}
					}
				})
			},
			/**
			 * @description 跳转个人主页
			 */
			issueDataMen(event) {
				console.log(event.gongdata);
				if (event.typedata == 1) { //普通用户
					this.$tools.push('/pages/user/userHome/index?id=' + event.testuser_id)
				} else { //名师
					this.$tools.push('/pages/teacher/teacherHome?id=' + event.testuser_id)
					let data = {
						id: event.testuser_id
					}
					this.$store.state.teacherData = data
					console.log(this.$store.state.teacherData);
				}
			},
			issueDataMen3(event) {
				console.log(event.gongdata);
				if (event.gongdata == 1) {
					if (event.typedata == 1) { //普通用户
						this.$tools.push('/pages/user/userHome/index?id=' + event.testuser_id)
					} else { //名师
						this.$tools.push('/pages/teacher/teacherHome?id=' + event.testuser_id)
						let data = {
							id: event.testuser_id
						}
						this.$store.state.teacherData = data
						console.log(this.$store.state.teacherData);
					}
				}
			},
			/**
			 * @description 发送语音、图片
			 */
			uploadPlugins(event) {
				if (event == 1) {
					// this.$tools.showToast('发语音')
					this.isRecordInfo = true // 开始语音追问
				} else if (event == 2) {
					this.isUpimage = true
				}
				this.uploadPluginsType = event
				this.isRecordType = 'add' //显示图标为下拉
				this.isRecordType2 = false // 初始化打开状态
				this.setInterDate = 0 //初始化倒计时
				this.recordType = 'not' //初始化位置
				clearInterval(this.isRecordStart) //销毁倒计时
				// this.isaddPlugins = !this.isaddPlugins
			},
			/**
			 * @description 选中评星
			 */
			starMen(event) {
				let array = []
				console.log(this.starList[event]);
				this.starList[event] = !this.starList[event]
				this.starList.forEach(item => {
					if (item == true) {
						array.push(item)
					}
				})
				this.assess = array.length
				this.$forceUpdate()
			},
			/**
			 * @description 提交选中的星
			 */
			starSubmit() {
				if (this.assess == 0) {
					this.$tools.showToast('不能评论0星')
					this.isRemark = false
					return false
				}
				let data = {
					order_id: this.issueId,
					assess: this.assess
				}
				this.$axios.axiosFrom('POST', evaluate_teacher, data)
					.then((res) => {
						if (res.code == 1) {
							this.isRemark = false
							this.$tools.showToast2(res.msg)
						} else {
							this.$tools.showToast(res.msg)
						}
					})
			},
			//对星星的评论
			xingEvaluate() {
				let self = this
				self.isRemark = true
				self.nums = 1
			},
			//控制语音
			recordSubmit(event) {
				this.recordType = event
				this.$tools.showToast('[状态]' + event)
				console.log('[录音状态]', event);
				if (event == 'start') {
					this.startRecord()
				} else if (event == 'not') { //取消按钮
					this.notRecord()
				} else if (event == 'out') { //暂停
					console.log('[暂停]', uni.showLoading({
						title: '语音生成中'
					}));
					uni.showLoading({
						title: '语音生成中'
					})
					setTimeout(r => {
						this.outRecord()
					}, 500)
				} else if (event == 'outStart') { //播放
					this.outStartRecord()
				}
			},
			//录音开始
			startRecord() {
				console.log('[开始录音]');
				this.isSetInterval() // 倒计时
				// #ifdef H5
				recorder.start();
				// #endif
			
				// #ifdef APP-PLUS || MP-WEIXIN
				recorderManager.start()
				// #endif
			},
			//倒计时
			isSetInterval() {
				this.isRecordStart = setInterval(r => {
					this.setInterDate++
				}, 1000)
			},
			//销毁录音 ， 取消
			notRecord() {
				console.log('[取消]');
				this.setInterDate = 0
				clearInterval(this.isRecordStart)
				uni.hideLoading()
			},
			//录音结束
			outRecord() {
				if (this.setInterDate < 3) {
					uni.hideLoading()
					this.setInterDate3()
				} else {
					this.setInterDate3t()
			
				}
			},
			//小于3秒的操作
			setInterDate3() {
				this.$tools.showToast('音频长度过短')
				clearInterval(this.isRecordStart) //销毁定时器
				this.setInterDate = 0 // 初始化定时器
				this.recordType = 'not' //初始化样式展示
			},
			//大于3的操作
			setInterDate3t() {
				clearInterval(this.isRecordStart)
				// #ifdef APP-PLUS
				recorderManager.stop()
				audioContext.pause(); //暂停 播放
				// #endif
			
				// #ifdef H5
				recorder.stop(); //结束录音
				let urlBold = this.convertToMp3(recorder.getWAV())
				this.audioUrl = URL.createObjectURL(urlBold)
				if (this.audioUrl) {
					uni.hideLoading()
					setTimeout(r => {
						uni.showToast({
							title: '语音生成成功',
							icon: 'none'
			
						})
					}, 100)
				}
				console.log('[生成文件流]', urlBold);
				console.log('[文件2]', this.convertToMp3(recorder.getWAV()));
				// #endif
			},
			//开始播放
			outStartRecord() {
				audioContext.play() //开始播放
			},
			recordTypeMen(event, event01) {
				console.log('[追答，回答]', event01);
				this.recordTypeData = event01
				this.isRecordType = event
				if (event == 'add') {
					this.isRecordType2 = true
				} else {
					this.isRecordInfo = false
					this.isUpimage = false
				}
			},
			convertToMp3(wavDataView) {
				// 获取wav头信息
				const wav = lamejs.WavHeader.readHeader(wavDataView); // 此处其实可以不用去读wav头信息，毕竟有对应的config配置
				const {
					channels,
					sampleRate
				} = wav;
				const mp3enc = new lamejs.Mp3Encoder(channels, sampleRate, 128);
				// 获取左右通道数据
				const result = recorder.getChannelData()
				const buffer = [];
			
				const leftData = result.left && new Int16Array(result.left.buffer, 0, result.left.byteLength / 2);
				const rightData = result.right && new Int16Array(result.right.buffer, 0, result.right.byteLength / 2);
				const remaining = leftData.length + (rightData ? rightData.length : 0);
			
				const maxSamples = 1152;
				for (let i = 0; i < remaining; i += maxSamples) {
					const left = leftData.subarray(i, i + maxSamples);
					let right = null;
					let mp3buf = null;
			
					if (channels === 2) {
						right = rightData.subarray(i, i + maxSamples);
						mp3buf = mp3enc.encodeBuffer(left, right);
					} else {
						mp3buf = mp3enc.encodeBuffer(left);
					}
			
					if (mp3buf.length > 0) {
						buffer.push(mp3buf);
					}
				}
			
				const enc = mp3enc.flush();
			
				if (enc.length > 0) {
					buffer.push(enc);
				}
			
				return new Blob(buffer, {
					type: 'audio/mp3'
				});
			},
			// 语音发送
			audioSubmit() {
				let self = this
				console.log('【地址】', upload);
				// this.setInterDate = 0
				this.isRecordInfo = false
				this.$tools.showToast('发语音')
				//语音上传
				// #ifdef H5
				this.audioContextSrc = this.audioUrl
				// #endif
				upAudio(this.audioContextSrc)
					.then(res => {
						if (res.code == 1) {
							console.log('录音',res.data.url);
							self.audioContextUrl = res.data.url
							this.addAnswerAudio()
							sekf.audioUrl = ''
						} else {
							this.$tools.showToast('上传失败')
						}
					})
			},
			// 发送语音接口
			// 语音回答接口
			addAnswerAudio() {
				console.log('[时长]', this.setInterDate);
				let data = {
					data: this.audioContextUrl,
					order_id: this.issueId,
					states: this.recordTypeData, //1回答 2追问 3 追答
					type: 3, //文字
					duration: this.setInterDate, //时长
				}
				this.$axios.axiosFrom('POST', addAnswer, data)
					.then((res) => {
						if (res.code == 1) {
							this.setInterDate = 0, // 初始化倒计时
								this.audioContextSrc = '' //初始化路径
							this.audioContextUrl = '' //初始化上传语音文件
							this.answerPage = 99999 //展开
							this.isRecordType = 'put'
							this.$tools.showToast('音频发送成功')
							this.answerListApi() //刷新
						} else {
							this.$tools.showToast(res.msg)
						}
					})
			},
			//名师语音播放
			voicePlay(event, item) {
				// this.$tools.showToast('进度条没做处理')
				let startDuration = 0
				console.log('【所有内容】', item);
				audioContext.src = event //数据传递给播放音频字段
				clearInterval(this.schedule) //销毁定时器
				this.answerList.forEach(item01 => {
					if (item.id == item01.id) {
						if (item01.isVoice == true) {
							item01.isVoice = false
							audioContext.play() //开始播放
							item01.schedule = 10 //先初始化
							console.log(Number(item.duration) * 100);
							this.schedule = setInterval(r => {
								item.schedule += (100 / Number(item.duration)) / 10
								this.$forceUpdate()
								startDuration += 0.1
								if (startDuration.toString().length > 6) {
									item.startDuration = startDuration.toString().substring(0, 3)
								} else {
									item.startDuration = startDuration
								}
			
								console.log(startDuration);
							}, 100)
							setTimeout(r => {
								item01.isVoice = true
								audioContext.stop() //停止播放
								// this.$tools.showToast('停止播放')
								item.startDuration = 0
								clearInterval(this.schedule) //销毁定时器
								this.$forceUpdate()
								item.schedule = 0
								// this.$tools.showToast('销毁定时器')
							}, Number(item.duration) * 1000)
						} else {
							clearInterval(this.schedule) //销毁定时器
							item01.schedule = 0 //先初始化
							item01.isVoice = true
							audioContext.stop() //停止播放
							this.$tools.showToast('停止播放')
							this.$forceUpdate()
							// audioContext.src = ''
						}
			
					} else {
						item01.isVoice = true
						item01.schedule = 0
						this.$forceUpdate()
					}
				})
				// item.isVoice = !item.isVoice
				// 	if (item.isVoice == false) {
			
				// 	} else {
				// 		item.isVoice = true // true是关闭
			
				// 		audioContext.src = ''
			
				// 	}
				this.$forceUpdate()
			
			},
			//登录跳转
			submitLogin() {
				this.isLoginInfo = false
				uni.reLaunch({
					url: '/pages/plugins/login/login'
				})
			},
			//预览图片
			previewImages(index, array) {
				console.log(index, array);
				preview(index, array)
			},
			//老师对问题详情进行回答
			addEvaluateMen5() {
				if (this.content == '') {
					return false
				}
				let data = {
					data: this.content,
					order_id: this.issueId,
					states: 1, //1回答 2追问 3 追答
					type: 1, //文字
				}
				this.$axios.axiosFrom('POST', addAnswer, data)
					.then((res) => {
						if (res.code == 1) {
							this.content = ''
							this.answerPage = 999999 //展开
							this.$tools.showToast('成功')
							this.answerListApi() //刷新
						} else {
							this.$tools.showToast(res.msg)
						}
					})
			},
			//滚动时触发
			// onPageScroll(event){
			// 	console.log('[滚动]',event.scrollTop);
			// },
			examineAll(event) {
				console.log(event);
				this.examineAllData = []
				this.examineAllData.push(event)
				this.modalName3 = 'bottomModal'
			},
			//收藏
			rightLike() {
				console.log('[收藏状态]', this.isLike);
				if (this.isLike != '1') {
					// this.$tools.showToast('进入收藏')
					let data = {
						bid: this.issueId, //问题id
						type: 1, //1是收藏问题 2是关注店铺
						state: 1, //1是添加2是列表
					}
					this.$axios.axiosFrom('POST', setCollectApi, data)
						.then((res) => {
							// console.log('[问题收藏]', res);
							if (res.code == 1) {
								this.isLike = '1'
								this.$tools.showToast2('收藏成功')
							} else if (res.code == 401) {
								this.isLoginInfo = true
							} else {
								this.$tools.showToast(res.msg)
							}
			
						})
				} else {
					let data = {
						bid: this.issueId, //问题id
						type: 1, //1是收藏问题 2是关注店铺
						state: 3, //1是添加2是列表
					}
					this.$axios.axiosFrom('POST', setCollectApi, data)
						.then((res) => {
							// console.log('[问题收藏]', res);
							if (res.code == 1) {
								this.isLike = '0'
								this.$tools.showToast('取消收藏')
							} else if (res.code == 401) {
								this.isLoginInfo = true
							} else {
								this.$tools.showToast(res.msg)
							}
			
						})
				}
			},
			rightShare() {
				// #ifdef H5
				this.isShare = true
				// #endif
			
				// #ifdef APP-PLUS
				this.isAppShare = true
				// #endif
			
			},
			setShareAddApi() {
				let data = {
					type: 1,
					id: this.issueId
				}
				this.$axios.axiosFrom("POST", setShareAddApi, data)
					.then((res) => {
						console.log('[分享]', res);
					})
			},
			//点赞
			comment_zanAdd(id, event) {
				// console.log('[点赞的内容]',event);
				let data = {
					comment_id: id,
					type: 1
				}
				this.$axios.axiosFrom('POST', comment_zanAdd, data)
					.then((res) => {
						if (res.code == 1) {
							event.zan++
						}
						this.$forceUpdate()
						this.$tools.showToast(res.msg)
					})
			},
			//追问
			addAnswer() {
				if (this.issueData <= 0) {
					this.$tools.showToast('没有追问次数了')
				} else {
					this.$tools.showToast('进行追问')
					this.nums = 4 //追问
				}
			},
			//追加名师点评-评论
			//追答
			addAnswersub2() {
			
				this.addAnswerStates = 3
				//追答
				this.addAnswersub()
			},
			addAnswersub() {
			
				if (this.content == '') {
					return false
				}
				let data = {
					order_id: this.issueId, //追加评论id
					states: this.addAnswerStates, //1回答2追问3追答
					type: this.addAnswerType, //1文字2图片3语音
					data: this.content, //追问内容
				}
				this.$axios.axiosFrom('POST', addAnswer, data)
					.then((res) => {
						if (res.code == 1) {
							console.log('[追问]', res);
							this.answerPage = 999999 //展开
			
							this.issueData.zhui-- //减少一次
							this.$tools.showToast(res.msg)
							this.answerListApi()
							this.content = ''
						} else {
							this.$tools.showToast(res.msg)
						}
					})
			},
			answerPageMen() {
				this.answerPage = 9999999
				this.examine = '1'
				// answerLength
				// examine
				this.answerListApi()
			},
			//回答列表- 名师点评
			answerListApi() {
				// if (this.examine == '收起') {
				// 	this.answerPage = 2
				// }
				let data = {
					order_id: this.issueId
				}
				this.$axios.axiosFrom('POST', answerListApi, data)
					.then((res) => {
						console.log('[名师点评]', res);
						if (res.code == 1) {
							this.answerLength = res.data.length //总长度
							this.answerList = []
							for (let i = 0; i < res.data.length; i++) {
								if (res.data[i].type == 3) {
									res.data[i].isVoice = true //是否显示 开关按钮
									res.data[i].videoData = '这里用来存放展示内容'
									res.data[i].schedule = 0 //默认进度条0
									res.data[i].startDuration = 0 //从0：00开始
								}
								this.answerList.push(res.data[i])
							}
						} else {
							this.answerList = []
						}
					})
			},
			//名师关注
			follow_add(event) {
				let data = {
					shi_id: event.ms_id,
					type: this.followType,
				}
				this.$axios.axiosFrom('POST', follow_add, data)
					.then((res) => {
						// console.log('[操作成功]', res);
						if (res.code == 1) {
							event.follow = 1
							this.$tools.showToast2('关注成功')
						} else if (res.code == 401) {
							this.submitLogin() //登录
						} else {
							this.$tools.showToast(res.msg)
						}
					})
					.catch(err => {})
			},
			/**
			 * @param 取消关注
			 */
			follow2(event) {
				let data = {
					type: 2,
					shi_id: event.ms_id,
				}
				this.$axios.axiosFrom('POST', follow_add, data)
					.then((res) => {
						console.log('[我的关注]', res);
						if (res.code == 1) {
							event.follow = 2
							// this.$tools.showToast(res.msg)
			
						} else {
							this.$tools.showToast(res.msg)
						}
					})
			},
			/**
			 * @param 触底刷新消息列表
			 */
			onReachBottom(e) {
				this.isLoding = true
				this.pageData++
				this.pageDataSize++
				this.comment_list()
				// console.log('触底！！！')
			},
			/**
			 * @param 获取评论列表
			 */
			comment_list() {
				let data = {
					order_id: this.issueId,
					// page: this.pageData,
					type: 1
				}
				this.$axios.axiosFrom('POST', comment_list, data)
					.then((res) => {
						if (res.code == 1) {
							console.log('[1级评论]', res);
			
							let dateTime = (new Date()).getTime(); //获取到阿当前时间
							res.data.list.forEach(item => {
								var date = new Date(item.createtime * 1000); //时间戳为10位需*1000，时间戳为13位的话不需乘1000
								var Y = date.getFullYear() + '-';
								var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date
									.getMonth() + 1) + '-';
								var D = (date.getDate() < 10 ? '0' + date.getDate() : date.getDate()) + ' ';
								var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours());
								var m = (date.getMinutes() < 10 ? '0' + date.getMinutes() : date
									.getMinutes()) + ':';
								var s = (date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds());
								// console.log('[时间]',dateTime - (item.createtime*1000) );
								if (item.createtime) {
									let presentTime = dateTime - (item.createtime * 1000)
									if (presentTime < 60000) {
										item.createtime = '刚刚'
									} else if (presentTime > 60000 && presentTime < 3600000) {
										item.createtime = (((presentTime / 1000 / 60) + '').split('.')[0]) +
											'分钟前'
									} else if (3600000 < presentTime && 86400000 > presentTime) {
										item.createtime = (((presentTime / 1000 / 60 / 60) + '').split('.')[
											0]) + '小时前'
									} else if (86400000 < presentTime && (86400000 * 2) > presentTime) {
										item.createtime = '昨天'
									} else if ((86400000 * 2) < presentTime && (86400000 * 3) > presentTime) {
										item.createtime = '前天' + h + ':' + s
									} else if ((86400000 * 3) < presentTime) {
										item.createtime = Y + M + D
									}
								}
								console.log(item);
			
							})
							this.commentList = res.data.list
			
			
						} else {
							// this.commentList =[] //如果失败 清空列表
							this.comment1Text = '暂无更多内容'
							// this.commentList2 = []//���空列表
						}
						this.isLoding = false //关闭下���刷新转圈
					})
					.catch(err => {
						this.isLoding = false //关闭下来刷新转圈
					})
			},
			/**
			 * @param 获取2级评论的评论id和用户名
			 */
			addEvaluate2(event, item02) {
				if (this.nums == 2) {
					return false
				}
				console.log(event.id);
				console.log(item02);
				this.nums = 3
				this.evaluateUser2 = item02.username
				this.evaluateUser2Id = event.id
				this.evaluatData = event
				this.busername = item02.username // 这个是上一级的人的名称
				this.$forceUpdate()
			},
			//追加评论
			addEvaluate(event) {
				if (this.nums == 2) {
					return false
				}
				this.nums = 0 //切换成追加评论
				this.addEvaluateId = event.id //1级消息id
				this.evaluateUser1 = event.username //用户的名称
				this.evaluatData = event
			},
			//对2级评论进行评论
			addEvaluateMen2() {
			
				// console.log('获取到的2级评论id--->', this.evaluatData);
				let array = []
				if (this.evaluatData.pdata) {
					array = this.evaluatData.pdata
				} else {
					this.evaluatData.pdata = []
				}
				console.log('三级评论', this.evaluatData.pdata);
			
			
			
				// return
				let data = {
					order_id: this.issueId,
					content: this.content, //评论内容
					type: 1, //1问题评论 2动态评论
					pid: this.evaluateUser2Id, //2级id
					busername: this.busername
				}
			
				console.log('[2级所有参数]', data);
			
			
				// return
				this.$axios.axiosFrom('POST', comment_add, data)
					.then((res) => {
						if (res.code == 1) {
			
							array.push(...array, res.data)
							// this.commentList2 = array
							// console.log('[2级列表]',this.commentList2);
							let array02 = Array.from(new Set(array))
							// console.log('二级评论',array02);
							this.evaluatData.pdata = array02
							this.content = '' //清空输入框
							// this.comment_list()
							console.log('三级评论', this.evaluatData.pdata);
							// this.$tools.showToast(res.msg)
						} else {
							this.$tools.showToast(res.msg)
						}
						console.log('发表成功===>', res);
					})
			},
			//发表评论
			commentAdd() {
				let self = this
				if (self.content == '') {
					self.$tools.showToast('请输入评论的内容！')
					return false
				}
				let data = {
					order_id: self.issueId,
					content: self.content, //评论内容
					type: 1, //1问题评论 2动态评论
					pid: '0'
				}
			
				self.$axios.axiosFrom('POST', comment_add, data)
					.then((res) => {
						if (res.code == 1) {
							self.commentListLength++
							// self.commentList.unshift(res.data)// 发出的消息整合
							console.log(this.commentList, '【总数居】');
							uni.pageScrollTo({ // 发表评论滚动到想要的位置
								scrollTop: 399,
								duration: 100
							});
							this.pageData = 1
							this.comment_list()
							self.issueData.reply_count++ //总评论数增加
							self.content = '' //清空输入框
						} else {
							self.$tools.showToast(res.msg)
							self.content = '' //清空输入框
						}
						console.log('发表成功===>', res);
					})
			},
			//addEvaluates发布追加评论
			addEvaluates() {
				// console.log('[所有评论列表]',);
				let array = []
				if (this.evaluatData.pdata) {
					array = this.evaluatData.pdata
				} else {
					this.evaluatData.pdata = []
				}
				console.log(this.evaluatData);
				// return
				if (this.content == '') {
					this.$tools.showToast('请输入评论的内容！')
					return false
				}
				let data = {
					order_id: this.issueId,
					content: this.content, //评论内容
					type: 1, //1问题评论 2动态评论
					pid: this.addEvaluateId // 追评id
				}
				this.$axios.axiosFrom('POST', comment_add, data)
					.then((res) => {
						if (res.code == 1) {
							array.push(...array, res.data)
							// this.commentList2 = array
							// console.log('[2级列表]',this.commentList2);
							let array02 = Array.from(new Set(array))
							console.log('二级评论', array02);
							this.evaluatData.pdata = array02
							this.content = '' //清空输入框
						} else {
							this.$tools.showToast(res.msg)
						}
						// console.log('发表成功===>', res);
					})
			},
			//取消围观
			cancel() {
				this.isCancel = false
			},
			//提交围观订单
			submit() {
				this.isCancel = false
				this.circuseePryApi()
			},
			// 1元围观下单接口
			circuseePryApi() {
				let data = {
					order_id: this.issueId
				}
				this.$axios.axiosFrom('POST', circuseePryApi, data)
					.then((res) => {
						if (res.code == 1) {
							this.orderno = res.data.order_on //订单
							// #ifdef APP-PLUS
							this.orderPayMen()
							// #endif
							// #ifdef H5
							this.isWeixinMen()
							// #endif
						} else if (res.code == 401) {
							this.submitLogin() //登录
							console.log(this.isLodingInfo);
							this.$tools.showToast(res.msg)
						} else {
							this.$tools.showToast(res.msg)
						}
						console.log('成功反的参数', );
					})
					.catch(err => {
			
					})
			},
			/**
			 *  微信内核
			 */
			//支付方式
			orderPayMen2() {
				let that = this
				uni.showActionSheet({
					itemList: ['微信支付', '余额支付'],
					success: function(res) {
						if (res.tapIndex == 0) {
							that.paytype = 6
							that.wxpayh5Notify()
						} else if (res.tapIndex == 1) {
							that.paytype = 7
							that.paymentApi()
						}
					}
				});
			},
			//支付方式
			orderPayMen() {
				let that = this
				uni.showActionSheet({
					itemList: ['支付宝', '微信支付', '余额支付'],
					success: function(res) {
						if (res.tapIndex == 0) {
							// #ifdef APP-PLUS
							that.paytype = 1
							// #endif
							// #ifdef H5
							that.paytype = 4
							// #endif
							that.paymentApi()
						} else if (res.tapIndex == 1) {
							// #ifdef APP-PLUS
							that.paytype = 2
							that.paymentApi()
							// #endif
							// #ifdef H5
							that.wxpayH5()
							// #endif
						} else {
							that.paytype = 7
							that.paymentApi()
						}
					},
					fail: function(res) {
						// console.log(res.errMsg);
						// this.$tools.showToast(res.errMsg)
						// this.$tools.showToast('失败')
					}
				});
			},


		}
	}
</script>

<style scoped>
	.swiper_image{
		width: 750rpx;
		height: 449rpx;
		opacity: 1;
	}
	.gonggao{
		width: 710rpx;
		height: 100rpx;
		background: #FFFFFF;
		opacity: 1;
		border-radius: 8rpx;
		margin: 0 auto;
		margin-top: 20rpx;
		margin-bottom: 20rpx;
	}
	.classify {
	}

	.classify_size {
		height: 82rpx;
		width: 82rpx;
	}

	.solid-bottom {
		border-bottom: 4rpx solid #000000;
	}
</style>
